﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class shop_getUserInfo : System.Web.UI.Page
{

  protected void Page_Load(object sender, EventArgs e)
  {
    DoWith();
  }
 
  private void DoWith()
  {
      string redirectUrl = Request.Url.ToString();
      Cms.BLL.wx_info info = new Cms.BLL.wx_info();
      string appid = info.GetModel(1).AppId;
      string appsecret = info.GetModel(1).AppSecret;

      if (Request.QueryString["code"] != null && Request.QueryString["code"] != "")
      {

          string Code = Request.QueryString["code"].ToString();
          string result = wxuserinfo.getwxCode(Code, redirectUrl);
      }
      else
      {
          string posturl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + appid + "&redirect_uri=" + redirectUrl + "&response_type=code&scope=snsapi_base&state=123#wechat_redirect ";
          //HttpContext.Current.Response.Redirect(posturl, true);
          string mss = Cms.Common.Utils.HttpPost(posturl, "");
      }
      //string poststr = "";
      //HttpContext.Current.Response.ContentType = "text/xml";
      //if (HttpContext.Current.Request.HttpMethod.ToLower() == "post")
      //{
      //    Stream s = System.Web.HttpContext.Current.Request.InputStream;
      //    byte[] b = new byte[s.Length];
      //    s.Read(b, 0, (int)s.Length);
      //    poststr = Encoding.UTF8.GetString(b);

      //    HttpContext.Current.Response.ContentType = "text/xml";
      //    //writelog(poststr);

      //    wxuserinfo.getUser_info(poststr);
      //}
      //else
      //{

      //}
  }

    
}